﻿#region Using

using PMSystem.ApplicationLogics;
using PMSystem.DataAccess;
using PMSystem.DataAccess.DataRepository;
using PMSytem.Windows.App;
using PMSytem.Windows.App.Util;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;

#endregion Using

namespace PMSytem.Windows.Tests
{
   

    public partial class SearchAudit : ToolWindow
    {
        
        private ObservableCollection<Audit> datasource =
        new ObservableCollection<Audit>();
        AuditService _service;


        #region Constructor

        public SearchAudit()
        {
            InitializeComponent();
            DataContext = this;
            _service = new AuditService();
        }

       

        #endregion Constructor

        public bool HasPermissions
        {
            get { return LoginUser.IsUserHasEditPermission; }
        }

        #region btnSearch_Click

        public ObservableCollection<Audit> RecordItemCollection
        {
            get
            {
                return datasource;
            }
        }

        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            datasource.Clear();
            try
            {
                var results = _service.GetAuditsBySearch(txtSearch.Text);

                foreach (var item in results)
                {
                    datasource.Add(item);
                }

            }
            catch (Exception ex)
            {
                var errr = ex.Message;
            }
        }

        #endregion btnSearch_Click



       
        
    }

   
    
}